<template>
  <div align="center">
    <div style="height:600px">
        <el-dialog :visible.sync="dialogVisible">
            <img width="100%" :src="img" alt="">
        </el-dialog>
      <div style="border:1px solid #000;margin:50px;" v-for="(r_ReportToUploadList,i) in r_ReportToUploadList" @click="select(r_ReportToUploadList.id)">
            <el-row>
                <el-col :span="24"><div class="grid-content bg-purple-dark">体检时间：{{r_ReportToUploadList.orderdate}}</div></el-col>
                <el-col :span="12"><div class="grid-content bg-purple-dark">姓名</div></el-col>
                <el-col :span="12"><div class="grid-content bg-purple-dark">{{r_ReportToUploadList.hMemberofthefile.hName}}</div></el-col>
                <el-col :span="12"><div class="grid-content bg-purple-dark">档案号</div></el-col>
                <el-col :span="12"><div class="grid-content bg-purple-dark">{{r_ReportToUploadList.hMemberofthefile.hFn}}</div></el-col>
                <el-col :span="12"><div class="grid-content bg-purple-dark">体检套餐</div></el-col>
                <el-col :span="12"><div class="grid-content bg-purple-dark">{{r_ReportToUploadList.setmeal.name}}</div></el-col>
            </el-row>
      </div>
    </div>
      <div>
          <el-pagination
                    background
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="1"
                    :page-sizes="[5, 10, 20]"
                    :page-size="5"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="ReportTotal"
                >
          </el-pagination>
      </div>
  </div>
</template>

<script>
import { listSelectTOrder, getTOrderById, removeTOrder } from "@/api/RReporttoupload";

export default {
    data(){
        return{
            dialogVisible: false,
            img:"",
            ReportTotal: 0,
            r_ReportToUploadList: [],
            search: {
                offset: 1,
                limit: 5,
                name:sessionStorage.getItem('is_loginID')
            },
        }
    },
    methods:{
        select(id){
            getTOrderById(id)
            .then((response) => {
                console.log(response);
                this.img=response.data.img
                if(this.img!=null&&this.img!=""){
                    this.dialogVisible = true;
                }else{
                    this.$message({
                        showClose: true,
                        message: "获取体检信息失败",
                        type: "error",
                    });
                }
            })
            .catch((error) => {
                console.log(error);
            });
        },
        getReportList() {
            listSelectTOrder(this.search)
            .then((response) => {
                console.log(response);
                this.ReportTotal = response.data.total;
                this.r_ReportToUploadList = response.data.rows;
            })
            .catch((error) => {
                console.log(error);
            });
        },
        handleSizeChange(val) {
            this.search.limit = val;
            this.search.offset = 1;
            this.getReportList();
        },
        handleCurrentChange(val) {
            this.search.offset = val;
            this.search.currentPage = val;
            this.getReportList();
        },
        outputError(error) {
            console.log(error.response ? error.response : error.message);
             this.loading = false;
            this.$message({
                showClose: true,
                message: "出错了，请按F12查看浏览器日志。",
                type: "error",
            });
        },
    },
    created(){
        if (window.sessionStorage) {
            const data = sessionStorage.getItem("is_login");
            console.log(data);
            if (data!=null && data!="") {
                console.log(12)
            } else {
                this.$router.push({
                path: '/patientlogin',
                })
                return
            }
        }
        this.getReportList();
    }
}
</script>

<style>

</style>